using MicroMsg.UI.Page;
using System;
using System.Collections.Generic;
using System.Windows.Documents;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class BaseInlineProcess
	{
		protected double mNFontSize = 20.0;
		protected Brush mBrushText;
		protected Brush mBrushLink;
		public virtual void ConfigTextApearence(int nFontSize = 0, Brush brushLink = null, Brush brushText = null)
		{
			this.mNFontSize = (double)nFontSize;
			if (nFontSize != 0)
			{
				this.mNFontSize = (double)nFontSize;
			}
			else
			{
				this.mNFontSize = 20.0;
			}
			if (brushLink != null)
			{
				this.mBrushLink = brushLink;
			}
			else
			{
				this.mBrushLink = R.theme.COMMON_BRUSH;
			}
			if (brushText != null)
			{
				this.mBrushText = brushText;
				return;
			}
			SolidColorBrush solidColorBrush = new SolidColorBrush();
			solidColorBrush.set_Color(Color.FromArgb(255, 255, 255, 255));
			this.mBrushText = solidColorBrush;
		}
		protected string GetMaxString(string string_0, int MaxLen)
		{
			if (string.IsNullOrEmpty(string_0))
			{
				return string_0;
			}
			if (string_0.get_Length() <= MaxLen)
			{
				return string_0;
			}
			return string_0.Substring(0, MaxLen) + "...";
		}
		public void ProcessText(List<InLineResult> inputText)
		{
			if (inputText == null)
			{
				return;
			}
			for (int i = inputText.get_Count() - 1; i >= 0; i--)
			{
				if (inputText.get_Item(i).mInline == null)
				{
					List<InLineResult> list = this.DivisionText(inputText.get_Item(i).mText);
					if (list != null && list.get_Count() > 0)
					{
						inputText.RemoveAt(i);
						for (int j = list.get_Count() - 1; j >= 0; j--)
						{
							inputText.Insert(i, list.get_Item(j));
						}
					}
				}
			}
		}
		protected virtual List<InLineResult> DivisionText(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return null;
			}
			List<InLineResult> list = new List<InLineResult>();
			int num = this.GetProbablyStartPos(text, 0);
			while (num >= 0 && num < text.get_Length())
			{
				int num2 = 0;
				string mText = "";
				Inline currentElement = this.GetCurrentElement(text, num, ref num2, ref mText);
				if (currentElement == null)
				{
					num++;
					num = this.GetProbablyStartPos(text, num);
				}
				else
				{
					if (num == 0)
					{
						list.Add(new InLineResult
						{
							mText = mText,
							mInline = currentElement
						});
					}
					else
					{
						string mText2 = text.Substring(0, num);
						list.Add(new InLineResult
						{
							mText = mText2
						});
						list.Add(new InLineResult
						{
							mText = mText,
							mInline = currentElement
						});
					}
					text = text.Substring(num + num2, text.get_Length() - num - num2);
					num = 0;
				}
			}
			if (!string.IsNullOrEmpty(text))
			{
				list.Add(new InLineResult
				{
					mText = text
				});
			}
			return list;
		}
		protected virtual int GetProbablyStartPos(string text, int startIndex)
		{
			throw new NotImplementedException();
		}
		protected virtual Inline GetCurrentElement(string text, int startIndex, ref int elementLen, ref string elementStr)
		{
			throw new NotImplementedException();
		}
		public BaseInlineProcess()
		{
			SolidColorBrush solidColorBrush = new SolidColorBrush();
			solidColorBrush.set_Color(Color.FromArgb(255, 255, 255, 255));
			this.mBrushText = solidColorBrush;
			this.mBrushLink = R.theme.COMMON_BRUSH;
			base..ctor();
		}
	}
}
